home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / tools / distlist < prev    next >
Text File  |  1993-11-08  |  2KB  |  68 lines

  1. #! /bin/sh
  2.  
  3. # distlist: create a list of files to distribute
  4. #
  5. # usage: distlist [ -p prefix ] [ machtype ... ]
  6.  
  7. # This script generates a list of files obtained from FILES files in a
  8. # directory tree.  Specifically, it lists the files in the file FILES
  9. # from the current directory, then recursively from the subdirectories
  10. # given by the DISTDIRS macro in the Makedefs file, as well as the
  11. # files in certain object directories (see below).  Files are listed
  12. # one per line and are prefixed with the pathname of the containing
  13. # directory, relative to the directory in which the script is first
  14. # invoked.
  15.  
  16. # The machtype arguments determine which object directories are
  17. # included.  Each machtype argument should be the name of an
  18. # object subdirectory (O.sgi, O.next, etc).  If no object subdirs
  19. # are specified, all those present are included.
  20.  
  21. # In general the prefix argument is used only by this script when it
  22. # invokes itself recursively.
  23.  
  24. # We assume the shell var GEOM is set to the root of the geom tree
  25.  
  26. prefix=.
  27. if [ "$1" = "-p" ] ; then
  28.   prefix=$2 ;
  29.   if [ -n "$VERBOSE" ]; then echo "distlist $prefix" >&2; fi
  30.   shift 2 ;
  31. else
  32.   # If no -p, we're the top-level script, so unique-ify our files.
  33.   # Also filter out embedded ..'s
  34.   $0 -p ./Geomview "$@" | sed -e "/\.\./s:/[^/]*/\.\./:/:g" | sort -u
  35.   exit
  36. fi
  37.  
  38. machargs="$*"
  39.  
  40. if [ $# = 0 ] ; then
  41.   machdistdirs="O.*"
  42.   ourtest=: ;
  43. else
  44.   machdistdirs="$*"
  45.   ourtest='! -d $dir/O.*' ;
  46.   for mach in $machdistdirs ; do
  47.     ourtest='-d $dir/'$mach' -o '"$ourtest" ;
  48.   done ;
  49.   ourtest='test '"$ourtest" ;
  50. fi
  51.  
  52. if [ -f FILES ] ; then
  53.   sed -e "s:^:$prefix/:" FILES
  54. fi
  55.  
  56. if [ -f Makedefs ] ; then
  57.   distdirs=`make DISTDIRS` ;
  58.   for dir in $distdirs $machdistdirs ; do
  59.     if test -d $dir && eval "$ourtest" ; then
  60.         ( cd $dir ; $GEOM/tools/distlist -p $prefix/$dir $machargs ) ;
  61.     fi
  62. # oh sed god do thy thing!
  63.   done | sed -e 's:/[^/][^/]*/\.\./:/:' ;
  64. fi
  65.  
  66. # The above sed command replaces srings of the form "/xxx/../"
  67. # with a single "/":
  68.